﻿using ConfExpert.Forms.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevTeam;
using DevExpress.Utils;

namespace ConfExpert.Forms.Siparisler
{
    public partial class SiparisAdetKontrol : XForm
    {
        public SiparisAdetKontrol()
        {
            InitializeComponent();
        }

        private void SiparisAdetKontrol_Load(object sender, EventArgs e)
        {
            this.Text = "Sipariş Kontrol Formu";

            gridView1.Init("GetSiparisAdetKontrol"); 

            
            gridView1.AddDetailGrid(gridView2, "CustomerId");
            gridView2.MakeColumnInvisible("CustomerId");

            gridView2.RowCellStyle += gridView2_RowCellStyle;
            gridView1.FocusedRowChanged += gridView1_FocusedRowChanged;
            gridView2.AddSummary("T_SiparisAdet,S_SiparisAdet".Split(",".ToCharArray()));
            
            gridView1.BestFitColumns();
            gridView2.BestFitColumns();
        }

        void gridView2_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                /*
                string Durum = gridView1.GetRowCellValue(e.RowHandle, "Durum").ToStr();
                if (Durum == "Eksik")
                    e.Appearance.BackColor = Color.Pink;*/

                switch (e.Column.FieldName)
                {
                    case "Fark":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        return;
                    case "T_SiparisAdet":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        return;
                    case "S_SiparisAdet":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        return;
                }
            }
        }

        void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            gridView2.BestFitColumns();
        }
    }
}
